<template>
  <el-form ref="form" :model="form" label-width="80px">

    <el-form-item label="账号">
      <el-input v-model="form.account"></el-input>
    </el-form-item>

    <el-form-item label="密码">
      <el-input v-model="form.password"></el-input>
    </el-form-item>

    <el-form-item label="姓名">
      <el-input v-model="form.realName"></el-input>
    </el-form-item>

    <el-form-item label="年龄">
      <el-input v-model="form.age"></el-input>
    </el-form-item>

    <el-form-item label="性别">
      <el-input v-model="form.gender"></el-input>
    </el-form-item>

    <el-form-item label="描述">
      <el-input v-model="form.description"></el-input>
    </el-form-item>

    <el-form-item label="科室">
      <el-select v-model="form.postId" placeholder="请选择科室">
        <el-option
          v-for="item in departmentList"
          :key="item.id"
          :label="item.name"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item >

    <el-form-item label="职位">
      <el-select v-model="form.roleId" placeholder="请选择科室">
        <el-option
          v-for="item in roleList"
          :key="item.id"
          :label="item.roleName"
          :value="item.id">
        </el-option>
      </el-select>
    </el-form-item >

    <el-form-item label="电话">
      <el-input v-model="form.telephone"></el-input>
    </el-form-item>

    <el-form-item>
      <el-button type="primary" @click="onSubmit">立即创建</el-button>
      <el-button>取消</el-button>
    </el-form-item>

  </el-form>
</template>

<script>

  //导入科室列表api
  import {getAlldepartment} from "@/api/appointment/appointment"

  import {
    getAllRole,
    addOnePerson
  } from '@/api/hr/Hr'
    export default {
        data(){
          return {
            form:{
              account:'',
              password:'',
              realName:'',
              age:'',
              gender:'',
              description:'',
              roleId:'',
              postId:'',
              // createUserId:'',
              // createTime:'',
              // updateUserId:'',
              // updateTime:'',
              telephone:'',
              // status:''

            },
            departmentList:[

            ],
            roleList:[

            ],
          }
        },
      methods:{

        getRoleList(){
          getAllRole().then(res=>{
            this.roleList=res.content
          }).catch(err => {
            console.log(err)
          })
        },

        getAllDepartment(){
          getAlldepartment().then(res=>{
            this.departmentList=res.content
          }).catch(err => {
            console.log(err)
          })
        },
        onSubmit(){
          addOnePerson(this.form).then(res=>{
            if(res.code==20000){
              this.form={}
            }
            alert(res.msg)
          })
        }
      },
      mounted(){

          this.getAllDepartment(),
          this.getRoleList()
      }
    }
</script>

<style scoped>

</style>
